﻿using System.Linq.Expressions;
using SqlSugar;

namespace Shop.Repository
{
    public interface IShopBaseRepository<T, IdentityId> where T : class, new()
    {
        bool IsExist ( Expression<Func<T, bool>> where );

        int Count ( Expression<Func<T, bool>> where );

        void Delete ( IdentityId id );

        void Delete ( IdentityId[] ids );

        T Get ( IdentityId id );

        T Find ( IdentityId id );
        Result Max<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, Result>> selector );

        Result Min<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, Result>> selector );

        Result Get<Result> ( IdentityId id ) where Result : class;

        Result Get<Result> ( IdentityId id, Expression<Func<T, Result>> selector );

        Result Get<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, Result>> selector );

        Result Get<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, Result>> selector, string orderBy );

        Result[] Gets<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, Result>> selector );


        Result[] Gets<Result> ( Expression<Func<T, bool>> where ) where Result : class, new();

        Result[] GetTops<Result> ( int top, string orderBy ) where Result : class, new();

        Result[] GetTops<Result> ( int top, string sortBy, OrderByType type ) where Result : class, new();
        Result[] GetTops<Result> ( Expression<Func<T, bool>> filter, int top, string orderBy ) where Result : class, new();
        Result[] GetTops<Result> ( Expression<Func<T, bool>> filter, Expression<Func<T, Result>> selector, int top, string orderBy );
        Result[] Gets<Result> ( Expression<Func<T, bool>> where, string orderBy ) where Result : class, new();

        Result Get<Result> ( Expression<Func<T, bool>> where ) where Result : class;
        T[] GetAll ();
        Result[] GetAll<Result> ( Expression<Func<T, Result>> selector );
        Result[] GetAll<Result> () where Result : class, new();
        Result[] GetAll<Result> ( string orderBy ) where Result : class, new();
        T[] Gets ( IdentityId[] ids );

        Result[] Gets<Result> ( IdentityId[] ids ) where Result : class;

        Result[] Gets<Result> ( IdentityId[] ids, Expression<Func<T, Result>> selector );

        Result[] GroupBy<Result> ( Expression<Func<T, bool>> where, Expression<Func<T, object>> group, Expression<Func<T, Result>> selector );

        bool Update<Set> ( T source, Set set );
        bool Update ( T source, params string[] cols );
    }
}